<?php
$title = "Add Page";
$url = "add-page";
$metadescription = "Create and publish a new page";
include('connpress/templates/add-page-head.php');
echo ('<title>'.$title.'</title>
<meta name="description" content="'.$metadescription.'" />');?>
<script type="text/javascript" src="connpress/tinymce/js/tinymce/tinymce.min.js"></script>
<script>
tinymce.init({
    selector: "textarea#area1",
    theme: "modern",
    height: 300,
    plugins: [
         "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
         "save table contextmenu directionality emoticons template paste textcolor jbimages"
   ],
   content_css: "tinymce.css?" + new Date().getTime(),
   toolbar: "undo redo | styleselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link | jbimages | image | print | preview | media | fullpage | forecolor backcolor | code", 
   style_formats: [
		{title: 'H1 Heading', block: 'h1'},
		{title: 'H2 Heading', block: 'h2'},
		{title: 'H3 Heading', block: 'h3'},
		{title: 'H4 Heading', block: 'h4'},
		{title: 'H5 Heading', block: 'h5'},
		{title: 'H6 Heading', block: 'h6'},
		{title: 'Paragraph', block: 'p'},
        {title: 'Bold', inline: 'b'},
        {title: 'Italics', inline: 'i'},
        {title: 'Underline', inline: 'u'},
        {title: 'Strikethrough', inline: 'strike'},
        {title: 'PRE', inline: 'span', classes: 'pre'},
        {title: 'CODE', inline: 'span', classes: 'code'},
        {title: 'Largest', inline: 'span', classes: 'largest'},
        {title: 'Large', inline: 'span', classes: 'large'},
        {title: 'Normal', inline: 'span', classes: 'normal'},
        {title: 'Small', inline: 'span', classes: 'small'},
        {title: 'Smallest', inline: 'span', classes: 'smallest'},
    ]
 }); 
</script>
<?php flush();
include('connpress/templates/add-page-page-top.php');
include('connpress/page-creator.php'); 
?>
<div style="width:960px;margin: 10px auto; padding-right:5px; padding-left:5px;">
<p><a href="index.php">Home</a> | <a href="<?php echo $url; ?>.php"><?php echo $title; ?></a> | <a href="add-page-mobile.php">Add Page Mobile</a></p>
</div>
<form method="post" action="#">
<input type="hidden" name="url" value="blank">
<input type="hidden" name="commentform" value="yes">
<input type="hidden" name="pagedate" value="<?php echo date('D, M d Y, g:ia T'); ?>">
<input type="hidden" name="authorname" value="Connga">
<input type="hidden" name="authorurl" value="index.php">
<div style="width:960px;margin: 10px auto;">
<h3>Title: <input type="text" style="width:600px; height:25px; font-size:24px;" name="title" value="">
</h3>
</div>
<h3>Description:</h3>
<textarea style="width:935px;margin-left:10px; height:50px; font-size:18px;" name="metadescription" value=""></textarea>
<div style="width:935px;margin-top:20px;margin-left:10px;">
<textarea name="content" id="area1"></textarea>
</div>
<div style="width:960px;margin: 10px auto; padding-right:10px; padding-left:10px;">
<input style="font-size:24px;" type="submit" value="Publish">
</div>
</form>
<?php
$date = date('m-d-Y-Hi-');
	if(isset($_FILES['image'])){
		$errors= array();
		$file_name = $_FILES['image']['name'];
		$file_size =$_FILES['image']['size'];
		$file_tmp =$_FILES['image']['tmp_name'];
		$file_type=$_FILES['image']['type'];   
		$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
		
		$expensions= array("jpeg","jpg","png"); 		
		if(in_array($file_ext,$expensions)=== false){
			$errors[]="extension not allowed, please choose a JPEG or PNG file.";
		}
		if($file_size > 10097152){
		$errors[]='The Image Can Be No Larger Than 10 MB';
		}				
		if(empty($errors)==true){
		$file_name = $date.$file_name;
			move_uploaded_file($file_tmp,"images/".$file_name);
			echo "<div style=\"width:960px;margin: 10px auto; padding-right:10px; padding-left:10px;\">";
			echo "<h2>Image Uploaded Successfully.</h2>";
			echo "<p><a target='_blank' href='images/".$file_name."'><img style='max-width:640px' src='images/".$file_name."'></a></p>";
			echo "<p>Here's the direct link: <a target='_blank' href='images/".$file_name."'>CLICK HERE</a></p>";
			echo "<p><a href='image-upload.php'>UPLOAD ANOTHER IMAGE</a></p>";
			echo "</div>";
		}else{
			print_r($errors);
		}
	}
?>
<div style="width:960px;margin: 10px auto; padding-right:10px; padding-left:10px;">
<h2>Manual Image Uploader</h2>
<p>Use the form below to manually upload an image to the server. From there you can drag it up to the body.</p>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" value="Upload" />
</form>
</div>
<?php include('connpress/templates/add-page-footer.php');
?>
